<template>
  <a-drawer
    v-model:visible="vdata.visible"
    :title=" true ? '结算详情' : '' "
    :body-style="{ paddingBottom: '80px' }"
    width="40%"
    @close="onClose"
  >
    <a-row justify="space-between" type="flex">
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="结算ID">
            {{ vdata.detailData.id }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="支付订单号">
            {{ vdata.detailData.payOrderId }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="支付金额">
            {{ (vdata.detailData.payOrderAmount/100).toFixed(2) }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="商品标题">
            {{ vdata.detailData.payOrderSubject }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="渠道订单号">
            {{ vdata.detailData.channelOrderNo }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="商户号">
            {{ vdata.detailData.subMchId }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="提现状态">
            {{ vdata.detailData.state == 1 ? '待结算' 
              : vdata.detailData.state == 2 ? '结算中' 
                : vdata.detailData.state == 3 ? '结算成功' 
                  : vdata.detailData.state == 4 ? '结算失败' 
                    : vdata.detailData.state == 5 ? '结算待重试' 
                      : '未知' }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="重试次数">
            {{ vdata.detailData.retryCount }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
     
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="创建时间">
            {{ vdata.detailData.createdAt }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="更新时间">
            {{ vdata.detailData.updatedAt }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
    </a-row>
    <a-divider />
    <a-row justify="start" type="flex">
      <a-col :sm="24">
        <a-form-item label="调起接口信息">
          <a-textarea
            v-model:value="vdata.detailData.applyInfo"
            disabled="disabled"
            style="height: 100px;color: black"
          />
        </a-form-item>
      </a-col>
    </a-row>
  </a-drawer>
</template>

<script lang="ts" setup>
import { API_URL_ZFT_SETT_RECORD, req } from '@/api/manage'
import {reactive} from 'vue'

const vdata:any = reactive({
  btnLoading: false,
  detailData: {}, // 数据对象
  recordId: null, // 更新对象ID
  visible: false, // 是否显示弹层/抽屉
})

function show (recordId) { // 弹层打开事件
  
  vdata.recordId = recordId
  req.getById(API_URL_ZFT_SETT_RECORD, recordId).then(res => {
    vdata.detailData = res
  })
  vdata.visible = true
}
function onClose () {
  vdata.visible = false
}

defineExpose({
  show //抛出show函数给父组件
})
</script>
